<?php
/*
 * @Author: 李明
 * @Date: 2021-08-09 17:17:46
 * @LastEditTime: 2021-11-30 18:05:29
 * @LastEditors: 李明
 * @Description: 
 * @FilePath: /CRM2.0-PHP/app/Http/Middleware/AccessControlAllowOrigin.php
 * @山东壹零贰肆信息科技有限公司
 */

namespace App\Http\Middleware;

use Closure;

class AccessControlAllowOrigin
{
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @return mixed
     */
    public function handle($request, Closure $next)
    {
        header('Access-Control-Allow-Origin: *');
        header("Access-Control-Allow-Credentials: true");
        header("Access-Control-Allow-Methods: *");
        // header('Access-Control-Allow-Headers: Origin, Access-Control-Request-Headers, SERVER_NAME, Access-Control-Allow-Headers, cache-control, token, X-Requested-With, Content-Type, Accept, Connection, User-Agent, Cookie, X-XSRF-TOKEN');
        header("Access-Control-Allow-Methods: *");
        if ($request->getMethod() !== 'OPTIONS') {
            header("Access-Control-Expose-Headers: *");
        }
        return $next($request);
    }
}
